package com.whmnx.shop.ui.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.google.android.material.tabs.TabLayout;
import com.whmnx.shop.BR;
import com.whmnx.shop.R;
import com.whmnx.shop.databinding.FragmentShopDetailsBinding;
import com.whmnx.shop.databinding.FragmentShoppingBinding;
import com.whmnx.shop.ui.adapter.BaseFragmentPagerAdapter;
import com.whmnx.shop.ui.viewmodel.ShopDetailsModel;

import java.util.ArrayList;
import java.util.List;

import me.goldze.mvvmhabit.base.BaseFragment;

/**
 * author : huang
 * date   : 2020/9/23 0023 14:32
 * version: 1.0
 * @author Administrator
 */
public class ShopDetailsFragment extends BaseFragment<FragmentShopDetailsBinding, ShopDetailsModel> {
    @Override
    public int initContentView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return R.layout.fragment_shop_details;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public void initData() {
        super.initData();
        viewModel.initToolbar(this);

        List<Fragment> list = new ArrayList<>();
        list.add(new CommentFragment());
      //  list.add(new ConfirmOrderFragment());

        List<String> list2 = new ArrayList<>();
        list2.add("商品说明");
        list2.add("评论");

        //设置Adapter
        BaseFragmentPagerAdapter pagerAdapter = new BaseFragmentPagerAdapter(getChildFragmentManager(), list, list2);
        binding.viewPager.setAdapter(pagerAdapter);
        binding.tabs.setupWithViewPager(binding.viewPager);
        binding.viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(binding.tabs));
    }
}
